<?php

/**
 * This is the model class for table "schedule".
 *
 * The followings are the available columns in table 'schedule':
 * @property string $id
 * @property string $sid
 * @property string $project
 * @property string $module
 * @property string $function
 * @property string $detail
 * @property string $people
 * @property string $adder
 * @property string $dateline
 * @property string $addtime
 */
class Schedule extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'schedule';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('sid, project, module, function, detail, people, adder, dateline, addtime', 'required'),
			array('sid, adder', 'length', 'max'=>10),
			array('project, module, function', 'length', 'max'=>16),
			array('people', 'length', 'max'=>12),
			array('dateline, addtime', 'length', 'max'=>24),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, sid, project, module, function, detail, people, adder, dateline, addtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => '逻辑主键id自增',
			'sid' => '排期任务id',
			'project' => '项目',
			'module' => '模块',
			'function' => '功能',
			'detail' => '任务详情',
			'people' => '任务负责人',
			'adder' => '信息添加者',
			'dateline' => '截止时间',
			'addtime' => '添加时间',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('sid',$this->sid,true);
		$criteria->compare('project',$this->project,true);
		$criteria->compare('module',$this->module,true);
		$criteria->compare('function',$this->function,true);
		$criteria->compare('detail',$this->detail,true);
		$criteria->compare('people',$this->people,true);
		$criteria->compare('adder',$this->adder,true);
		$criteria->compare('dateline',$this->dateline,true);
		$criteria->compare('addtime',$this->addtime,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Schedule the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
